{
  "nbformat": 4,
  "nbformat_minor": 0,
  "metadata": {
    "colab": {
      "private_outputs": true,
      "provenance": [],
      "authorship_tag": "ABX9TyOjpmTOzsJP4UAmZbt4YoBk",
      "include_colab_link": true
    },
    "kernelspec": {
      "name": "python3",
      "display_name": "Python 3"
    },
    "language_info": {
      "name": "python"
    }
  },
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "view-in-github",
        "colab_type": "text"
      },
      "source": [
        "<a href=\"https://colab.research.google.com/github/alexfazio/crewAI-quickstart/blob/main/crewai_custom_tool_template_quickstart.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
      ]
    },
    {
      "cell_type": "markdown",
      "source": [
        "Github repo: https://github.com/alexfazio/crewai-quickstart\n",
        "\n",
        "Docs: https://docs.crewai.com/\n",
        "\n",
        "- Create a custom tool using crewAi's [BaseTool](https://docs.crewai.com/core-concepts/Tools/#subclassing-basetool) class\n",
        "\n",
        "Requirements:\n",
        "- [OpenAI](https://platform.openai.com/playground)/[Groq](https://console.groq.com/settings/organization)/[Anthropic](https://console.anthropic.com/dashboard) API Key\n",
        "- Serper API Key: https://serper.dev/"
      ],
      "metadata": {
        "id": "UcsQt3pIKXMe"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "# To create a personalized tool, inherit from BaseTool and define the necessary attributes and the _run method.\n",
        "\n",
        "from crewai_tools import BaseTool"
      ],
      "metadata": {
        "id": "QW3M0rxxJYNG"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "source": [
        "Every Tool needs to have a name and a description.\n",
        "\n",
        "When running locally, you can customize the code with your logic in the _run function."
      ],
      "metadata": {
        "id": "NAReTLDNJguV"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "class MyCustomTool(BaseTool):\n",
        "    name: str = \"Name of my tool\"\n",
        "    description: str = \"What this tool does. It's vital for effective utilization.\"\n",
        "\n",
        "    def _run(self, argument: str) -> str:\n",
        "        # Your tool's logic here\n",
        "        return \"Tool's result\""
      ],
      "metadata": {
        "id": "XfXeWU6gJVwM"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "Nj0WHrYDJQDh"
      },
      "outputs": [],
      "source": [
        "sentiment_analysis_tool = SentimentAnalysisTool()"
      ]
    }
  ]
}